const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const app = express();

// 静态文件服务
app.use(express.static('./dist'));

// 代理配置
app.use('/api', createProxyMiddleware({
    target: 'http://39.106.50.183:1000', // 后端服务器地址
    changeOrigin: true,
    pathRewrite: {
        '^/api': '' // 移除/api前缀
    }
}));

// 运行时的端口
const port = 7777;

app.listen(port, function (err) {
    if (err) {
        console.log(err);
        return;
    }
    console.log('Listening at http://localhost:' + port + '\n');
});